#!/usr/bin/env python3
import sqlite3
import os

def check_cache():
    db_path = 'crypto_data.db'
    if not os.path.exists(db_path):
        print(f"数据库文件不存在: {db_path}")
        return
    
    try:
        conn = sqlite3.connect(db_path)
        cursor = conn.cursor()
        
        # 检查表是否存在
        cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='technical_indicators_cache'")
        if not cursor.fetchone():
            print("technical_indicators_cache 表不存在")
            conn.close()
            return
        
        # 查看缓存表内容
        cursor.execute('SELECT * FROM technical_indicators_cache LIMIT 10')
        rows = cursor.fetchall()
        
        print("缓存表内容:")
        if rows:
            for row in rows:
                print(row)
        else:
            print("缓存表为空")
        
        # 查看表结构
        cursor.execute('PRAGMA table_info(technical_indicators_cache)')
        columns = cursor.fetchall()
        print("\n表结构:")
        for col in columns:
            print(col)
        
        conn.close()
        
    except Exception as e:
        print(f"检查缓存时出错: {e}")

if __name__ == '__main__':
    check_cache()